/*
 * MouseEvents_Bounds
 * 
 * PSprite provides a simple API for handling mouse events.
 * See MouseEvents_Simple for an introduction.
 * 
 * Many mouse events are only handled if they are within the bounds
 * of the PSprite instance.  Unlike ActionScript 3.0,
 * Processing Scenegraph requires that developers manually
 * update the bounds of PSprite instances using bounds(),
 * or boundsLeft, boundsTop, width, and height.
 * 
 * If a PSprite instance has not set its bounds via these
 * properties or methods, it will not respond properly to
 * mouse events that respond to the PSprite's bounds.
 * 
 * If a future version of Processing Scenegraph updates a
 * PSprite's bounds rect automatically as it changes, I will be happy.
 */

import com.transmote.psg.*;
import com.transmote.psg.events.*;

PSpriteContainer spriteContainer;

void setup () {
  size(400, 400);
  setupSprites();
}

void draw () {
  background(0);
  spriteContainer.update();
}

void setupSprites () {
  // create a PSpriteContainer to hold all other PSprites
  spriteContainer = new PSpriteContainer(this);
  
  // attach a ButtonSprite instance to the SpriteContainer
  ButtonSprite spriteLeft = new ButtonSprite();
  spriteLeft.x = 200;
  spriteLeft.y = 200;
  spriteContainer.addChild(spriteLeft);
}
